import { reqGetSearchInfo } from '@/api/index';

// search模块的小仓库
const state = {
  searchList: null,
};

const actions = {
  async getSearchList({ commit }, params = {}) {
    let result = await reqGetSearchInfo(params);
    if (result.code === 200) commit('GETSEARCHLIST', result.data);
  },
};

const mutations = {
  GETSEARCHLIST(state, searchList) {
    state.searchList = searchList;
  },
};

const getters = {
  attrsList() {
    return state.searchList?.attrsList ?? [];
  },
  goodsList() {
    return state.searchList?.goodsList ?? [];
  },
  trademarkList() {
    return state.searchList?.trademarkList ?? [];
  },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
};
